import { request } from "../utils"
import { Toast } from "vant"


/*
  获取门店课程活动
*/
const getShopProducts = (requestData, cb) => {
  request({
    url: "api/ShopBranchWeb/GetProductList",
    params: requestData
  }).then(res => {
    if (res.data.Success) {
      cb && cb(res.data.Data.Products)
    } else {
      console.log("获取门店课程活动失败...")
      Toast(res.data.Msg)
    }
  })
}

/*
  获取门店详情
*/
const getShopBranchInfo = (requsetData, cb) => {
  request({
    url: "api/ShopBranchWeb/GetShopBranchInfo",
    params: requsetData
  }).then(res => {
    if (res.data.Success) {
      cb && cb(res.data.Data)
    } else {
      console.log("获取门店详情失败...")
    }
  })
}

/*
  获取门店最新动态
*/
const getShopBranchNews = (requsetData, cb) => {
  request({
    url: "api/Article/GetShopArticles",
    params: requsetData
  }).then(res => {
    if (res.data.Success) {
      cb && cb(res.data.Data)
    } else {
      console.log("获取门店动态失败...")
    }
  })
}

/*
  获取退货地址
*/
const getShopGetAddress = (cb) => {
  request({
    url: "api/OrderRefund/GetShopGetAddress",
    params: {
      shopId: 1,
    },
  }).then((res) => {
    if (res.data.Success) {
      cb && cb(res.data.Data)
    } else {
      console.log("获取收货地址失败...")
    }
  })
}


export {
  getShopProducts,
  getShopBranchInfo,
  getShopBranchNews,
  getShopGetAddress,
}
